import re
from pathlib import Path
a = '''
    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentScriptType="application/ecmascript" contentStyleType="text/css" height="285px" preserveAspectRatio="none" style="width:718px;height:285px;" version="1.1" viewBox="0 0 718 285" width="718px" zoomAndPan="magnify">
'''
img_tag_regx = re.compile(r'(?P<tag><img\s+src=")(?P<path>)".*?/>')
svg_tag_regx = re.compile(r'<svg.+?>', re.DOTALL)
width_regx = re.compile(r'width="(?P<width>.*?)"')
height_regx = re.compile(r'height="(?P<height>.*?)"')


def update_svg_width_height(data):
    match = svg_tag_regx.search(data)
    if match:
        svg = match.group()
        width = width_regx.search(svg)['width']
        height = height_regx.search(svg)['height']
        return width,height

